package com.first.course.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.first.common.pojo.EduCourse;
import com.first.common.pojo.TbCheckCourse;
import com.first.course.mapper.EduCourseMapper;
import com.first.course.mapper.TbCheckCourseMapper;
import com.first.course.service.TbCheckCourseService;
import com.first.course.vo.EduCourseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @program: first-project
 * @description:
 * @author: 路志欣
 * @create: 2023-05-30 17:33
 **/
@Service
public class TbCheckCourseServiceImpl implements TbCheckCourseService {

    @Autowired
    private EduCourseMapper eduCourseMapper;

    @Autowired
    private TbCheckCourseMapper tbCheckCourseMapper;

    /**
     *
     * @param pageCurrent
     * @param pageSize
     * @param eduCourseVo
     * @return 查询课程审核
     */
    @Override
    public Page<EduCourse> findCheckCourse(Integer pageCurrent, Integer pageSize, EduCourseVo eduCourseVo) {
        Page<EduCourse> page = new Page<>(pageCurrent,pageSize);
        QueryWrapper<EduCourse> wrapper = new QueryWrapper<>();
        if(StringUtils.hasText(eduCourseVo.getTitle())){
            wrapper.like("c.title",eduCourseVo.getTitle());
        }
        if (StringUtils.hasText(eduCourseVo.getStatus())){
            wrapper.eq("status",eduCourseVo.getStatus());
        }
        wrapper.eq("cc.check_status",2);
        Page<EduCourse> page1 = eduCourseMapper.findCheckCourse(page, wrapper);
        return page1;
    }

    /**
     *
     * @param tbCheckCourse
     * @return 审核课程
     */
    @Override
    public Integer updateCourseCheck(TbCheckCourse tbCheckCourse) {
        int update = tbCheckCourseMapper.updateById(tbCheckCourse);
        return update;
    }

}
